#include <fstream>
#include <iostream>
#include <cctype>

using namespace std;

typedef istreambuf_iterator < char >buf_iter;

int map[256] = { 0 };

int numChars;

void
initTable ()
{
  numChars = 0;
  for (unsigned char c = 0; c <= 127; c++) {
    if (isalnum (c) || ispunct (c) || c == ' ')
      map[c] = ++numChars;
  }
}

void
makeVector (int i, ofstream & out)
{
  for (int j = 1; j <= numChars; j++) {
    if (j > 1)
      out << " ";
    out << ((j == i) ? "1" : "0");
  }
  out << endl;
}

int
main (int argc, char **argv)
{
  if (argc < 3) {
    cout << "usage: " << argv[0] << " <in> <out>" << endl;
    return 1;
  }
  ifstream file (argv[1]);
  ofstream out (argv[2]);
  initTable ();
  out << "? " << numChars << " " << numChars << endl;
  char c, lastc;
  int space = 0;
  int first = 1;
  for (buf_iter i (file), e; i != e; ++i) {
    c = *i;
    if (isalnum (c) || ispunct (c) || c == ' ' || c == '\n') {
      if (c == '\n')
	c = ' ';
      if (c != ' ' || !space) {
	//cout << map[(unsigned char)c] << endl;
	if (first)
	  first = 0;
	else {
	  makeVector (map[c], out);
	  makeVector (map[lastc], out);
	}
	lastc = c;
      }
      if (c == ' ')
	space = 1;
      else
	space = 0;
    }
  }
  return 0;
}
